-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed bug not sending all pending messages #44
base: master
Are you sure you want to change the base?
Conversation
This has solved most of my issues in a project im working on (using STM32G473). I was having similar issues where the sdo client / sdo_server got locked up because the TX buffer was full. Since implementing this patch the canopen stack is quite stable. |
I'm not sure about this solution. Stack must be fully stable, no messages lost, nothing. Here is similar code for PIC32, which makes no problems: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I encountered a similar issue in my project, where only the first 4 messages are sent when I need to send 6 TPDOs simultaneously. and I made the same modifications.
The STM32 has 3 CAN transmit mailboxes. When 6 messages are sent simultaneously, the first 3 messages are successfully placed into the mailboxes. After the first message is sent successfully, HAL_CAN_TxMailbox0CompleteCallback is called, then CO_CANinterrupt_TX is entered. At this point, mailbox 1 is empty, and mailboxes 2 and 3 are not empty. Message 4 is then placed into mailbox 1. Messages 5 and 6 are not sent because there are no available mailboxes. If the code does not break at this point, CANmodule->CANtxCount will be set to 0, and messages 5 and 6 will not be sent even when mailboxes become available.
the code you cited also includes the missing I removed the |
Good catch ! Looking at the code, I think you are right. I haven't test it myself but I believe it is a correct change, From my side, we can merge it in. @MaJerle do you approve as well ? |
In my application I always flag (setting
sendRequest
to true) 8 PDOs for sending at the same time and I was wondering why only the first 3 - 4 PDOs are transmitted.If the CO_CANinterrupt_TX is not able to send out all pending messages (e.g. if there are more pending messages than there are free CAN tx mailboxes) the CANtxCount is set to 0, which prohibits the sending of theses pending messages in the next interrupt.
I also stop the iteration if sending of one pending message fails, because following messages can also not be send if the buffers are already full.
I could not find an issue for this bug, if you like I can open one.